< previous page page_85 next page >

Page 85
Setting the dbDenyWrite option prevents other users from changing the data in the Dynaset while you have it open (similar to the Exclusive database property). The dbReadOnly option prevents you from changing the data in the Dynaset (similar to the ReadOnly database property). The dbAppendOnly option lets you add new data to the Dynaset but does not let you modify or delete existing records.
Setting the dbReadOnly option speeds processing of the Dynaset and is handy for generating displays or reports. The dbDenyWrite option is useful when you want to make major changes to the Dynaset and want to prevent other users from accessing the records in the Dynaset until you are done making your changes. Using the dbAppendOnly option lets you create data entry routines that limit user rights to adding records without deleting or modifying existing ones.
Now you'll add the code that sets the Options property of the data control. You'll notice that you do not have a property for each of the three options. How do you set them individually? You do this by adding up the constants and placing the result in the Options property of the data control.
For example, if you want to open the Dynaset for only appending new records, set the Options property of the data control to dbAppendOnly. If you want to open the Dynaset to deny everyone the right to update the database and to allow read-only access for the current user, set the Options property to dbDenyWrite + dbReadOnly.
For now, set the data control options to DenyWrite and ReadOnly. When you are done, your procedure should look like this:
Public Sub OpenDB()
   Dim cDBName As String    ' declare a string variable
   Dim cTblName As String   ' declare a string variable
   Dim bExclusive As Boolean ' declare true/false var
   Dim bReadOnly As Boolean ' declare true/false var
   '
   cDBName = "c:\tysdbvb5\source\data\books5.mdb" ' point to database
   cTblName = "Authors" ' point to authors table
   bExclusive = True ' set to exclusive open
   bReadOnly = True ' set to read only
   '
   Data1.DatabaseName = cDBName ' set database property
   Data1.RecordSource = cTblName ' set recordsource property
   Data1.Exclusive = bExclusive
   Data1.Options = dbDenyWrite + dbReadOnly
   Data1.ReadOnly = bReadOnly
   '
   Data1.Refresh ' update data control properties
End Sub

 
< previous page page_85 next page >

If you like this book, buy it!